var e = require;
var t = module;
var o = exports;
(o.__esModule = !0), (o.default = void 0);
var n = b(e("Params")),
    i = b(e("PDef")),
    a = b(e("PTT")),
    r = b(e("CCEngine")),
    s = b(e("LayaEngine")),
    d = b(e("PWX")),
    c = b(e("PQQ")),
    l = b(e("PBaiDu")),
    h = b(e("POppo")),
    u = b(e("PVivo")),
    p = b(e("PHuaWei")),
    f = b(e("PNative")),
    m = b(e("PGameBox4399")),
    g = b(e("PKuaiShou")),
    w = b(e("PH54399")),
    v = b(e("PUC"));

function b(e) {
    return e && e.__esModule ? e : { default: e };
}
(window.nativeChannel = ""),
(window.fuckyou = ""),
(window.CHANNEL = { web: "web", oppo: "Oppo", vivo: "vivoGame", tt: "TT", android: "Android", iOS: "iOS", qq: "qq" });
var S = (function() {
    function e() {
        (this.channel = "web"),
        (this.engine = "egret"),
        (this.label = null),
        (this.area = null),
        (this.platform = new i.default()),
        (this.wx = null),
        (this.systemInfo = {
            appName: "Platform.systemInfo default",
            windowWidth: 720,
            windowHeight: 1280,
            platform: window.cc ? "creator" : window.Laya || window.laya ? "laya" : "none"
        }),
        (this.llaburl = null),
        (this.myLocation = null),
        (this.params = n.default),
        (this.cparam = n.default.web),
        (this.labData = {}),
        (this.initChannelTimeout = null),
        (window.lplatform = this),
        lplatform.plog("plog open"),
            this.checkEngine(),
            this.checkChannel(),
            this.initChannel(),
            this.getArea(),
            (this.gameStartMS = Date.now()),
            (this.adSecondMax = 90),
            (this.adSecondNow = this.adSecondMax),
            (this.outRewardVideoCb = null),
            this.resetInterstitialPer60Second(),
            window.android && (nativeChannel = window.android.getNativeChannel());
    }
    var t = e.prototype;
    return (
        (t.checkSystemInfoAndAppName = function(e) {
            (this.wx = e),
            this.wx &&
                "function" == typeof this.wx.getSystemInfoSync &&
                (this.systemInfo = this.wx.getSystemInfoSync());
        }),
        (t.checkEngine = function() {
            window.cc && window.cc.director ?
                ((this.engine = "cc"), (this.uiEngine = new r.default())) :
                (window.Laya || window.laya) && ((this.engine = "laya"), (this.uiEngine = new s.default()));
        }),
        (t.checkChannel = function() {
            if (window.tt)
                this.checkSystemInfoAndAppName(window.tt), (this.channel = "TT"), (this.cparam = n.default.tt);
            else if (window.qg) {
                this.checkSystemInfoAndAppName(window.qg);
                var e = this.wx.getSystemInfoSync().brand;
                e &&
                    ((e = e.toLowerCase()),
                        (this.channel = "Oppo"),
                        (this.cparam = n.default.oppo),
                        e.indexOf("oppo") >= 0 ||
                        e.indexOf("OPPO") >= 0 ||
                        e.indexOf("Oppo") >= 0 ||
                        e.indexOf("REALME") >= 0 ||
                        e.indexOf("Realme") >= 0 ?
                        ((this.channel = "Oppo"), (this.cparam = n.default.oppo)) :
                        e.indexOf("vivo") >= 0 ||
                        e.indexOf("Vivo") >= 0 ||
                        e.indexOf("VIVO") >= 0 ||
                        e.indexOf("iqoo") >= 0 ||
                        e.indexOf("IQOO") >= 0 ?
                        ((this.channel = "vivoGame"), (this.cparam = n.default.vivo)) :
                        (e.indexOf("huawei") >= 0 ||
                            e.indexOf("honor") >= 0 ||
                            e.indexOf("Huawei") >= 0 ||
                            e.indexOf("HuaWei") >= 0 ||
                            e.indexOf("HONOR") >= 0) &&
                        ((this.channel = "huaWei"), (this.cparam = n.default.huawei)));
            } else
                window.swan ?
                (this.checkSystemInfoAndAppName(window.swan),
                    (this.channel = "BaiDu"),
                    (this.cparam = n.default.baidu)) :
                window.qq ?
                (this.checkSystemInfoAndAppName(window.qq), (this.channel = "qq"), (this.cparam = n.default.qq)) :
                window.hasOwnProperty("gamebox") ?
                (this.checkSystemInfoAndAppName(window.gamebox),
                    (this.channel = "gb4399"),
                    (this.cparam = n.default.gb4399)) :
                window.h5api ?
                (this.checkSystemInfoAndAppName(window.h5api),
                    (this.channel = "h54399"),
                    (this.cparam = n.default.h54399)) :
                window.ks || window.kwaigame ?
                (this.checkSystemInfoAndAppName(window.ks), (this.channel = "ks"), (this.cparam = n.default.ks)) :
                "undefined" != typeof uc ?
                (this.checkSystemInfoAndAppName(uc), (this.channel = "uc"), (this.cparam = n.default.uc)) :
                window.wx ?
                (this.checkSystemInfoAndAppName(window.wx), (this.channel = "wx"), (this.cparam = n.default.wx)) :
                "cc" == this.engine ||
                ("laya" == this.engine &&
                    (Laya.Browser.onAndroid ?
                        ((this.channel = "Android"), (this.cparam = n.default.native)) :
                        Laya.Browser.onIOS && ((this.channel = "iOS"), (this.cparam = n.default.native))));
            "web" == this.channel &&
                (window.android ?
                    ((this.channel = "Android"), (this.cparam = n.default.native)) :
                    window.webkit &&
                    window.webkit.messageHandlers &&
                    window.webkit.messageHandlers.jsToOcWithPrams &&
                    window.webkit.messageHandlers.jsToOcWithPrams.postMessage &&
                    ((window.ios = {}), (this.channel = "iOS"), (this.cparam = n.default.native))),
                lplatform.plog("checkChannel:" + this.channel);
        }),
        (t.initChannel = function() {
            this.platform && (this.platform.release(), (this.platform = null)),
                "TT" == this.channel ?
                (this.platform = new a.default()) :
                "gb4399" == this.channel ?
                (this.platform = new m.default()) :
                "h54399" == this.channel ?
                (this.platform = new w.default()) :
                "ks" == this.channel ?
                (this.platform = new g.default()) :
                "wx" == this.channel ?
                (this.platform = new d.default()) :
                "qq" == this.channel ?
                (this.platform = new c.default()) :
                "BaiDu" == this.channel ?
                (this.platform = new l.default()) :
                "Oppo" == this.channel ?
                (this.platform = new h.default()) :
                "vivoGame" == this.channel ?
                (this.platform = new u.default()) :
                "huaWei" == this.channel ?
                (this.platform = new p.default()) :
                "uc" == this.channel ?
                (this.platform = new v.default()) :
                "web" == this.channel ?
                (this.platform = new i.default()) :
                "cc" == this.engine ?
                (console.log("cocos web内嵌"), (this.platform = new f.default())) :
                "laya" == this.engine &&
                (Laya.Browser.onAndroid ?
                    (this.platform = new f.default()) :
                    Laya.Browser.onIOS ?
                    (this.platform = new f.default()) :
                    (console.log("使用laya web内嵌"), (this.platform = new f.default())));
        }),
        (t.getArea = function() {
            // "" != this.params.locationUrl &&
            //     (lplatform.plog("getArea " + this.params.locationUrl),
            // this.httpRequest(
            //     this.params.locationUrl,
            //     function(e, t, o) {
            //         if (e) lplatform.plog("getArea res:" + e);
            //         else {
            //             var n = JSON.parse(o);
            //             n && (this.myLocation = n.cityCode + "," + n.proCode),
            //                 lplatform.plog("getArea this.myLocation:" + this.myLocation);
            //         }
            //         this.getLabel();
            //     }.bind(this)
            // ));
        }),
        (t.getLabel = function() {
            // var e =
            //     n.default.llabHost +
            //     n.default.llabName +
            //     "/lab" +
            //     this.channel +
            //     nativeChannel +
            //     this.cparam.llabVer +
            //     ".json";
            // lplatform.plog("getLabel llaburl:" + e),
            //     this.httpRequest(
            //         e,
            //         function (e, t, o) {
            //             if (e) lplatform.plog("getLabel error:" + JSON.stringify(e));
            //             else {
            //                 lplatform.plog("getLabel resText:" + o);
            //                 var n = JSON.parse(o);
            //                 (this.labData = n || {}),
            //                     lplatform.plog("getLabel this.labData:" + JSON.stringify(this.labData));
            //             }
            //             this.initChannelTimeout && clearTimeout(this.initChannelTimeout),
            //                 this.startLabWhenGet(),
            //                 this.platform.initAD(),
            //                 this.labData.mainSwitch,
            //                 this.ipReg();
            //         }.bind(this)
            //     );
        }),
        (t.setLabDataToCParam = function() {
            if (this.labData)
                for (var e in this.labData) {
                    void 0 !== lplatform.cparam[e] &&
                        void 0 !== this.labData[e] &&
                        this.labData[e] &&
                        (lplatform.cparam[e] = this.labData[e]);
                }
        }),
        (t.startLabWhenGet = function() {
            if ((this.setLabDataToCParam(), this.labData)) {
                var e = this.labData.alwaysOn,
                    t = !1;
                if (this.labData.locationList || this.labData.province) {
                    this.labData.locationList = this.labData.province;
                    for (var o = 0; o < this.labData.locationList.length; o++) {
                        if (this.myLocation && this.myLocation.indexOf(this.labData.locationList[o]) >= 0) {
                            t = !0;
                            break;
                        }
                    }
                }
                t && (this.labData = {});
                var n = new Date(),
                    i = n.getHours(),
                    a = n.getMinutes();
                if (this.labData.time) {
                    var r = !1;
                    for (var s in this.labData.time) {
                        var d = this.labData.time[s][0].split(":"),
                            c = this.labData.time[s][1].split(":");
                        if (i >= d[0] && i < c[0] && a >= d[1]) {
                            r = !0;
                            break;
                        }
                        if (i >= d[0] && i == c[0] && a >= d[1] && a < c[1]) {
                            r = !0;
                            break;
                        }
                    }
                    r || (this.labData = {});
                }
                this.labData.mainSwitch || (this.labData = {}),
                    this.labData.openSceneValues &&
                    this.platform.checkOpenSceneValue &&
                    !this.platform.checkOpenSceneValue() &&
                    ((this.labData = {}), console.log("checkOpenSceneValue set labData = {}")),
                    this.labData.lockLocation ?
                    t && this.startLabWhenGet() :
                    (this.labData.openIntervalBanner &&
                        setInterval(
                            function() {
                                this.showBanner();
                            }.bind(this),
                            1e3 * this.labData.openIntervalBanner
                        ),
                        this.labData.openIntervalInterstitial &&
                        setInterval(
                            function() {
                                this.showInterstitial();
                            }.bind(this),
                            1e3 * this.labData.openIntervalInterstitial
                        ),
                        this.labData.openIntervalVideo &&
                        setInterval(
                            function() {
                                this.showRewardedVideo();
                            }.bind(this),
                            1e3 * this.labData.openIntervalVideo
                        ),
                        this.labData.openScreenVideo &&
                        ("TT" == this.channel ||
                            "qq" == this.channel ||
                            "wx" == this.channel ||
                            "ks" == this.channel ||
                            "gb4399" == this.channel ?
                            this.showRewardedVideo(function() {
                                this.showInterstitial(), this.showBanner();
                            }) :
                            this.showInterstitial())),
                    this.resetTimeVideoAd(),
                    this.resetInterstitialPer60Second(),
                    (this.labData.alwaysOn = e);
            }
            lplatform.plog("Over---labData:" + JSON.stringify(this.labData));
        }),
        (t.httpRequest = function(e, t, o, n, i, a, r) {
            if ((void 0 === o && (o = 3e3), "function" == typeof this.platform.httpRequest))
                this.platform.httpRequest(e, t, o, n, i, a, r);
            else {
                var s = new XMLHttpRequest();
                (s.timeout = o),
                (s.onreadystatechange = function() {
                    4 == s.readyState &&
                        (s.status >= 200 && s.status < 400 ?
                            t(null, s.response, s.responseText) :
                            t(s.status, null, null));
                }),
                s.open(n || "GET", e, !0),
                    s.send(i);
            }
        }),
        (t.native2JsEvent = function(e) {
            lplatform.plog("native2JsEvent str:" + e + " window.vcb:" + window.vcb),
                "playADSuccess" == e ?
                (window.vcb && (window.vcb(!0), (window.vcb = null)), lplatform.resumeGame()) :
                "playADFailed" == e &&
                (window.vcb && (window.vcb(!1), (window.vcb = null)), lplatform.resumeGame());
        }),
        (t.js2NativeEvent = function(e) {
            var t = !0;
            return (
                window.android ?
                window.android.js2NativeEvent(e) :
                window.ios ?
                window.webkit &&
                window.webkit.messageHandlers &&
                window.webkit.messageHandlers.jsToOcWithPrams &&
                window.webkit.messageHandlers.jsToOcWithPrams.postMessage ?
                window.webkit.messageHandlers.jsToOcWithPrams.postMessage({ params: e }) :
                console.error(this.engine + "ios微端 未实现webkit.messageHandlers以外，其他的js-原生通信方式") :
                "cc" == this.engine ?
                (t = !1) :
                "laya" == this.engine ?
                window.webkit &&
                window.webkit.messageHandlers &&
                window.webkit.messageHandlers.jsToOcWithPrams &&
                window.webkit.messageHandlers.jsToOcWithPrams.postMessage ?
                window.webkit.messageHandlers.jsToOcWithPrams.postMessage({ params: e }) :
                console.error(this.engine + " 未实现webkit.messageHandlers以外，其他的js-原生通信方式") :
                console.error(this.engine + " 未实现js2NativeEvent"),
                t
            );
        }),
        (t.pauseGame = function() {
            window.cc ?
                cc.audioEngine.pauseAll() :
                window.Laya && (Laya.SoundManager.setMusicVolume(0), Laya.SoundManager.setSoundVolume(0));
        }),
        (t.resumeGame = function() {
            window.cc ?
                cc.audioEngine.resumeAll() :
                window.Laya && (Laya.SoundManager.setMusicVolume(1), Laya.SoundManager.setSoundVolume(1));
        }),
        (t.analytics = function(e, t) {
            this.platform.analytics(e, t), this.engine;
        }),
        (t.showFavoriteGuide = function() {
            this.platform.showFavoriteGuide();
        }),
        (t.showBanner = function() {
            this.platform.showBanner();
        }),
        (t.showDelayBanner = function(e) {
            return (
                (e = e || 2e3),
                setTimeout(
                    function() {
                        this.showBanner();
                    }.bind(this),
                    e
                )
            );
        }),
        (t.hideBanner = function() {
            this.platform.hideBanner();
        }),
        (t.showInterstitial = function() {
            this.resetInterstitialPer60Second(), this.platform.showInterstitial();
        }),
        (t.showDelayInterstitial = function(e) {
            return (
                (e = e || 2e3),
                setTimeout(
                    function() {
                        this.showInterstitial();
                    }.bind(this),
                    e
                )
            );
        }),
        (t.showInterstitialPer60Second = function() {
            this.canShowInterstitial60Second && this.showInterstitial();
        }),
        (t.showDelayInterstitialPer60Second = function(e) {
            return this.canShowInterstitial60Second ? this.showDelayInterstitial(e) : null;
        }),
        (t.resetInterstitialPer60Second = function(e) {
            var t = this;
            void 0 === e && (e = 10),
                this.labData.interstitial90RealTime && (e = this.labData.interstitial90RealTime),
                (this.canShowInterstitial60Second = !1),
                this.interstitial60Timeout &&
                (clearTimeout(this.interstitial60Timeout), (this.interstitial60Timeout = null)),
                (this.interstitial60Timeout = setTimeout(function() {
                    t.canShowInterstitial60Second = !0;
                }, 1e3 * e));
        }),
        (t.hideInterstitial = function() {
            this.platform.hideInterstitial();
        }),
        (t.showRanRewardedVideo = function(e) {
            if (
                ((this.outRewardVideoCb = e),
                    console.log("mainSwitch:", this.labData.mainSwitch, "playVideo:", this.labData.playVideo),
                    this.labData.mainSwitch && null != this.labData.playVideo)
            ) {
                var t = Math.random();
                console.log("rand:", t),
                    t <= this.labData.playVideo ? this.showRewardedVideo(e) : this.pRewradVideoCb(!0);
            } else this.showRewardedVideo(e);
        }),
        (t.showRewardedVideo = function(e) {
            (this.outRewardVideoCb = e), this.platform.showRewardedVideo(this.pRewradVideoCb.bind(this));
        }),
        (t.hideRewardedVideo = function() {
            this.platform.hideRewardedVideo();
        }),
        (t.createMoreGamePortal = function() {
            this.platform.createMoreGamePortal();
        }),
        (t.createMoreGameBanner = function() {
            this.platform.createMoreGameBanner();
        }),
        (t.canRecord = function() {
            return this.platform.canRecord();
        }),
        (t.canShareRecord = function() {
            return this.platform.canShareRecord();
        }),
        (t.makeShareUI = function(e, t, o, n, i) {
            void 0 === n && (n = 0), void 0 === i && (i = !1), this.platform.makeShareUI(e, t, o, n, i);
        }),
        (t.startRecord = function(e) {
            this.platform.startRecord(e);
        }),
        (t.pauseRecord = function() {
            this.platform.pauseRecord();
        }),
        (t.stopRecord = function(e) {
            this.platform.stopRecord(e);
        }),
        (t.shareRecord = function(e, t) {
            this.platform.shareRecord(e, t);
        }),
        (t.resetRecord = function() {
            this.platform.resetRecord();
        }),
        (t.shareInnerRecord = function(e, t) {
            this.platform.shareInnerRecord(e, t);
        }),
        (t.createMoreGameButton = function() {
            this.platform.createMoreGameButton();
        }),
        (t.goToGameOrGameList = function(e) {
            this.platform.goToGameOrGameList(e);
        }),
        (t.followAccount = function() {
            this.platform.followAccount();
        }),
        (t.openAwemeUserProfile = function() {
            this.platform.openAwemeUserProfile();
        }),
        (t.createGameClub = function() {
            this.platform.createGameClub();
        }),
        (t.navigateToMiniProgram = function(e) {
            this.platform.navigateToMiniProgram(e);
        }),
        (t.shareMessageToFriend = function() {
            this.platform.shareMessageToFriend();
        }),
        (t.sendMsgToOpenDataProject = function(e) {
            this.platform.sendMsgToOpenDataProject(e);
        }),
        (t.plog = function() {
            var e;
            this.cparam.showLog && (e = console).log.apply(e, arguments);
        }),
        (t.showLoading = function(e) {
            this.platform.showLoading(e);
        }),
        (t.hideLoading = function() {
            this.platform.hideLoading();
        }),
        (t.pRewradVideoCb = function(e) {
            this.outRewardVideoCb && (this.outRewardVideoCb(e), (this.outRewardVideoCb = null)),
                this.resetTimeVideoAd();
        }),
        (t.timeVideoAd = function(e) {
            var t = !1;
            return (
                (this.adSecondMax = lplatform.labData.interstitial90RealTime || this.adSecondMax),
                console.log("timeVideoAd adSecondNow:" + this.adSecondNow + " this.adSecondMax:" + this.adSecondMax),
                lplatform.labData.interstitial90RealTime && 0 == this.adSecondNow ?
                (this.resetTimeVideoAd(),
                    "iOS" == lplatform.channel || lplatform.channel,
                    lplatform.showRewardedVideo(e || function() {}.bind(this)),
                    (t = !0),
                    lplatform.analytics("timeVideoAd", {})) :
                e && e(!1),
                t
            );
        }),
        (t.resetTimeVideoAd = function() {
            (this.adSecondMax = lplatform.labData.interstitial90RealTime || this.adSecondMax),
            console.log("resetTimeVideoAd adSecondMax:" + this.adSecondMax),
                (this.adSecondNow = this.adSecondMax),
                this.adTimeout && clearTimeout(this.adTimeout),
                (this.adTimeout = setTimeout(
                    function() {
                        this.adSecondNow = 0;
                    }.bind(this),
                    1e3 * this.adSecondMax
                ));
        }),
        (t.showRandVideo = function(e, t) {
            this.labData.playVideo && Math.random() <= this.labData.playVideo ?
                this.showRewardedVideo(function(o) {
                    o ? e && e() : t && t();
                }) :
                t && t();
        }),
        (t.ipReg = function() {
            this.labData.getIP &&
                window.wx &&
                wx.request({
                    url: "https://lab.bwyxa.com/api/userinfo",
                    data: {},
                    header: { "content-type": "application/json" },
                    success: function success() {},
                    fail: function fail() {}
                });
        }),
        e
    );
})();
(o.default = S), (t.exports = o.default);